<template>
  <el-container class="layout-container">
    <el-aside width="200px">
      <el-menu
        :router="true"
        :default-active="$route.path"
        class="el-menu-vertical"
        text-color="#ffffff"
        active-text-color="#ffffff"
        background-color="#1e2d3d"
      >
        <div class="logo-container">
          <img src="../assets/logo.png" alt="Logo" class="logo">
        </div>
        
        <el-menu-item index="/student/test">
          <el-icon><Document /></el-icon>
          <span>MBTI测试</span>
        </el-menu-item>
        
        <el-menu-item index="/student/profile">
          <el-icon><User /></el-icon>
          <span>个人信息</span>
        </el-menu-item>
      </el-menu>
    </el-aside>

    <el-container>
      <el-header>
        <div class="header-content">
          <h2>MBTI职业性格测试系统 - 学生端</h2>
          <div class="user-info">
            <span>{{ userStore.userInfo?.fullName }}</span>
            <el-button link @click="handleLogout">退出登录</el-button>
          </div>
        </div>
      </el-header>

      <el-main>
        <router-view />
      </el-main>
    </el-container>
  </el-container>
</template>

<script setup>
import { useRouter } from 'vue-router'
import { useUserStore } from '../stores/user'
import { ElMessage } from 'element-plus'

const router = useRouter()
const userStore = useUserStore()

const handleLogout = () => {
  userStore.logout()
  ElMessage.success('退出登录成功')
  router.push('/login')
}
</script>

<style scoped>
.layout-container {
  height: 100vh;
}

.el-aside {
  background-color: #1e2d3d;
  color: #ffffff;
}

.el-menu-vertical {
  border-right: none;
  background-color: #1e2d3d;
}

.el-menu-vertical :deep(.el-menu-item) {
  color: #ffffff;
}

.el-menu-vertical :deep(.el-menu-item.is-active) {
  background-color: #1890ff;
  color: #ffffff;
}

.el-menu-vertical :deep(.el-menu-item:hover) {
  background-color: #263445;
  color: #ffffff;
}

.logo-container {
  height: 60px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 10px 0;
}

.logo {
  height: 40px;
  width: 40px;
}

.el-header {
  background-color: #fff;
  border-bottom: 1px solid #dcdfe6;
  padding: 0 20px;
}

.header-content {
  height: 60px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

.el-main {
  padding: 20px;
  background-color: #f5f7fa;
}
</style> 